<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <title>博客</title>
    <!-- 1. 导入CSS的全局样式 -->
    <link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet">
    <!-- 2. jQuery导入，建议使用1.9以上的版本 -->
    <script src="${pageContext.request.contextPath}/js/jquery-2.1.0.min.js"></script>
    <!-- 3. 导入bootstrap的js文件 -->
    <script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>

</head>
<body>
<div class="container">
    <div style="margin: 5px">
        <a class="btn btn-primary" href="${pageContext.request.contextPath}/UserBlog/findBlogByPage">返回主页</a>
    </div>
    <p style="text-align: center;" class="bg-info">---</p>

    <h2 style="text-align: center;">Blog</h2>

    <%--作者头像展示--%>
    <p align="right">
        <img src="${pageContext.request.contextPath}/headImg/${requestScope.author_user.path}" width="150" height="150"
             class="img-thumbnail">
        <br>作者&nbsp:&nbsp <a class="btn btn-default"
                             href="${pageContext.request.contextPath}/UserBlog/authorHome?id=${requestScope.author_user.id}&bid=${sessionScope.blog.id}"
                             role="button">${requestScope.author_user.username}</a>
    </p>


    <!-- 显示的信息框 -->
    <c:if test="${requestScope.userlike_msg!=null}">
        <div class="alert alert-warning alert-dismissible" role="alert">
            <button type="button" class="close" data-dismiss="alert">
                <span>&times;</span></button>
            <strong>${requestScope.userlike_msg}</strong>
        </div>
    </c:if>


    <h3 style="text-align: center;">${sessionScope.blog.title}</h3>
    <textarea class="form-control" rows="20" name="content" readonly="readonly">${sessionScope.blog.content}</textarea>

    <%--展示图片的--%>
    <c:if test="${requestScope.blogImages.size()!=0}">
        <c:forEach items="${requestScope.blogImages}" var="images" varStatus="s">
            <img src="${pageContext.request.contextPath}/${images.path}" width="500" height="300">
        </c:forEach>
    </c:if>
    <%--收藏键相关操作--%>

    <c:if test="${requestScope.likestatus}">
        <a style="align :center;margin: 5px" class="btn btn-primary"
           href="${pageContext.request.contextPath}/UserLike/userLike?status=delete&id=${sessionScope.blog.uid}&uid=${sessionScope.user.id}&bid=${sessionScope.blog.id}">收藏</a>
    </c:if>
    <c:if test="${!requestScope.likestatus}">
        <a style="align :center;margin: 5px" class="btn btn-default"
           href="${pageContext.request.contextPath}/UserLike/userLike?status=add&id=${sessionScope.blog.uid}&uid=${sessionScope.user.id}&bid=${sessionScope.blog.id}">收藏</a>
    </c:if>

    <%--这下面的评论有关的了--%>
    <p style="text-align: center;" class="bg-info">---</p>
    <h4 style="text-align: center;">评论区<small>快来留下你的评论吧</small></h4>
    <form action="${pageContext.request.contextPath}/BlogComment/addComment?bid=${sessionScope.blog.id}&uid=${sessionScope.user.id}"
          method="post">
        <textarea class="form-control" rows="4" name="comment" placeholder="请在此输入评论"></textarea>
        <input style="margin:5px" class="btn btn btn-primary" type="submit" value="提交">
    </form>
    <!-- 显示的信息框 -->
    <c:if test="${requestScope.comment_msg!=null}">
        <div class="alert alert-warning alert-dismissible" role="alert">
            <button type="button" class="close" data-dismiss="alert">
                <span>&times;</span></button>
            <strong>${requestScope.comment_msg}</strong>
        </div>
    </c:if>
    <p style="text-align: center;" class="bg-info">---</p>
    <%--这下面的每一个评论都能点击弹出输入框--%>

    <c:forEach items="${requestScope.commentList}" var="comment" varStatus="s">
        <blockquote>
            <p>${comment.content} <a style="right: auto"
                                     href="${pageContext.request.contextPath}/BlogComment/replyComment?bid=${comment.blogid}&prior=${comment.id}&cuid=${comment.userid}"
                                     class="btn btn-default btn-xs " role="button">查看回复</a>
                <c:if test="${comment.userid==sessionScope.user.id}">
                    <a style="right: auto"
                       href="${pageContext.request.contextPath}/BlogComment/deleteComment?cid=${comment.id}&bid=${comment.blogid}"
                       class="btn btn-default btn-xs " role="button">删除</a>
                </c:if>
            </p>
        </blockquote>
    </c:forEach>
    <p style="text-align: center;" class="bg-info">---</p>
</div>
</body>
</html>
